from src.Tool.csv_vision import MOOCSentimentVisualizer
import json

# 加载 JSON 文件数据
with open('static/user_data/result/result.json' , 'r', encoding='utf-8') as file:
    data = json.load(file)

# 确保 `data` 是一个列表的格式，并传入 MOOCSentimentVisualizer
# 创建 MOOCSentimentVisualizer 实例
visualizer = MOOCSentimentVisualizer(data)

# 生成并保存图像
visualizer.plot_final_sentiment_distribution(save_path='static/user_data/result/final_sentiment_distribution.png')
visualizer.plot_aspect_frequency(save_path='static/user_data/result/aspect_frequency.png')
visualizer.plot_sentiment_word_frequency(save_path='static/user_data/result/sentiment_word_frequency.png')
